// function copy(data) {
//   const temp = []
//   for (const [key, v] of Object.entries(data)) {
//     temp[key] = typeof v === 'object' ? copy(v) : v
//   }
//   return temp
// }
// const data = ['yahoo', 'google', 'facebook', ['新浪']]

// $new = copy(data)
// $new[3][0] = '抖音'

// console.log(data)
const Tool = {
  copy(data) {
    const temp = data instanceof Array ? [] : {}
    for (const [key, v] of Object.entries(data)) {
      temp[key] = typeof v === 'object' ? this.copy(v) : v
    }
    return temp
  },
}

const data = [
  { name: 'IPAD', price: 199 },
  { name: 'ThinkPad Carbon X1', price: 9999 },
  { name: 'macbook Air m1', price: 7000 },
]
$new = Tool.copy(data)
$new[0].price = 3800
// $new.lesson.title = '视频'
console.table($new)

console.table(data)

// console.log(data)
// let a = {}
// let key = 'name'
// a[key] = 'yahoo'

// console.log(a)
